************************************************************************.
****** (additional analyses can start in the middle of this file) ******.
************************************************************************.
*First 3 commands can be asterisked later .

GET DATA /TYPE=XLS
   /FILE='airdem.xls'
   /SHEET=name 'AIRDEMO'
   /CELLRANGE=full
   /READNAMES=on
   /ASSUMEDSTRWIDTH=32767.

DELETE VARIABLES rt1_s rt2_s dPlt a0 TO a35 .

SAVE OUTFILE = "temp.sav" .

GET FILE = "temp.sav" .

CORRELATIONS qtryhard qpushfast qdeserve qslavery .
FREQUENCIES qtryhard qpushfast qdeserve qslavery .
* Symbolic racism for item scale: .
* Items should be scored so that racism is high .
* These are instructions from PJ Henry .

* 1. "It's really a matter of some people not trying hard enough; if
* Blacks would only try harder they could be just as well off as Whites."
* (1, strongly agree; 2, somewhat agree; 3, somewhat disagree; 4, strongly
* disagree).
* Reverse this item .
COMPUTE qtryhard = 5 - qtryhard .

* 2. "Generations of slavery and discrimination have created conditions
* that make it difficult for blacks to work their way out of the lower
* class." (1, strongly agree; 2, somewhat agree; 3, somewhat disagree; 4,
* strongly disagree). This item then is reverse-coded. 
* (No reversal needed) .
 
* 3. "Over the past few years, blacks have gotten less than they deserve."
* (1, strongly agree; 2, somewhat agree; 3, somewhat disagree; 4, strongly
* disagree). This item then is reverse-coded. 
* (No reversal needed) .
 
* 4. "Some say that Black leaders have been trying to push too fast.
* Others feel that they haven't pushed fast enough. What do you think?"
* (1, trying to push too fast; 2, going too slowly; 3=moving at about the
* right speed). 

* If higher numbers indicate more symbolic racism, then the highest score 
* should be given to "trying to push too fast." The middle score should be "moving 
* at about the right speed," and the lowest score for "going too slowly." .
* Recode this acc. to PJ's instructions .

RECODE qpushfast (1=3) (3=2) (2=1) .

CORRELATIONS qtryhard qpushfast qdeserve qslavery .

RELIABILITY
  /VARIABLES=qtryhard qpushfast qdeserve qslavery
  /SCALE('ALL VARIABLES')  ALL/MODEL=ALPHA.

*alpha goes up only slightly, from .664 to .679 if qpushfast is dropped.

COMPUTE conservatism = 0 - politicalid .
FORMATS conservatism (F2.0) .
FREQUENCIES politicalid conservatism .

COMPUTE symb_racism = SUM(qtryhard, qpushfast, qdeserve, qslavery) .
CORRELATIONS symb_racism conservatism qtryhard qpushfast qdeserve qslavery .

*ewhtblk is the thermometer difference.  It's not needed (rename the other) .

RENAME VARIABLES 
  (forcechoice = forcechoice_McCain) (ewhtblk = race_th_dif) (eObmMccain = cand_th_dif) .

SORT CASES BY subject .

*Check for duplicate records .
COMPUTE FLAG_repeat = 0 .
IF (LAG(subject) = subject) FLAG_repeat = 1 .
FREQUENCIES FLAG_repeat .
SELECT IF (FLAG_repeat = 0) .
EXECUTE .

MATCH FILES FILE = * / FILE = "IAT.1_line_per_subject.sav" / BY subject .
EXECUTE .

COMPUTE VoteMcCain = 1 - VoteObama .
FREQUENCIES race voteMcCain forcechoice_McCain .

COMPUTE white = (race = "white") .
COMPUTE mixed = (race = "mixed") .
COMPUTE black = (race = "black") .
EXECUTE .

*Save enlarged version of data file.
SAVE OUTFILE = "temp.sav" .

***************************************************.
****** (additional analyses can start here) *******.
***************************************************.
GET FILE = "temp.sav" .

*Definition of "filter$" (quoted from syntax that computed IAT measures) .
*COMPUTE filter$ = (ntrials=96) & (pct_300<10) & (pct_2K<20) & (error_pct<35) & (aveltncy<1700) .
FREQUENCIES filter$ .

DESCRIPTIVES forcechoice_McCain raceinfluence attpol cand_th_dif conservatism VoteMcCain . 
*Reverse "cand_th_dif" measure .
COMPUTE cand_th_dif = 0 - cand_th_dif .

*Standardize variables in preparation for logistic regression .
AGGREGATE OUTFILE = * MODE = ADDVARIABLES 
 / BREAK = filter$  
 / SD_D_biep SD_D_biep_all SD_D_biep_x SD_D_biep_a SD_D_biep_b SD_amp
    SD_cand_th_dif SD_race_th_dif SD_attpol SD_attrace SD_conserv SD_symb_racism
  = SD(D_biep D_biep_all D_biep_x D_biep_a D_biep_b amp 
      cand_th_dif race_th_dif attpol attrace conservatism symb_racism) .

RENAME VARIABLES (filter$ = IAT_filter$) .
*Limit analyses to respondents who showed good cooperation with instructions on all three IATs.
FILTER BY iat_filter$ .
COMPUTE race_IAT_d = D_biep / SD_D_biep .
COMPUTE race_IATall_d = D_biep_all / SD_D_biep_all .
COMPUTE race_IATx_d = D_biep_x / SD_D_biep_x .
COMPUTE race_IATa_d = D_biep_a / SD_D_biep_a .
COMPUTE race_IATb_d = D_biep_b / SD_D_biep_b .
COMPUTE race_amp_d = amp / SD_amp .
COMPUTE race_th_df_d = race_th_dif / SD_race_th_dif .
COMPUTE attrace_d = (attrace-4) / SD_attrace .
COMPUTE symb_racism_d = symb_racism / SD_symb_racism .
COMPUTE cand_th_df_d = cand_th_dif / SD_cand_th_dif .
COMPUTE attpol_d = (attpol-4) / SD_attpol .
COMPUTE conservatism_d = conservatism / SD_conserv .
EXECUTE .

*Apply selection criteria for AMP .
*Keith Payne's advice (from email to me of 7 Nov 08):.  
*I exclude subjects with 100% uniform responses for
*either prime category, and those who say that they can read the
*characters or speak Chinese. This is typically about 2-3% and I think it
*would be reasonable to exclude a higher proportion on the basis of
*extreme responding in some cases. In the case of internet data, for
*example, I would think there is a greater need for data cleaning than
*with lab data, so it may be worthwhile to exclude outliers using
*traditional metrics (e.g., 3SD beyond the mean).

FILTER OFF .
FORMAT amp race_amp_d (F5.3) .
*FREQUENCIES amp race_amp_d / FORMAT = NOTABLE / HISTOGRAM .
*This computes a 3 SD filter for the amp measure.
COMPUTE amp_filter$ = (race_amp_d >= -2.97 AND race_amp_d <= 3.07) .
COMPUTE combined_filter$ = (amp_filter$=1 AND iat_filter$=1) .
FREQUENCIES race .
COMPUTE IAT_race_filter$ = (iat_filter$=1 & orgn = "us" & race ne "black") .
COMPUTE AMP_race_filter$ = (amp_filter$=1 & orgn = "us" & race ne "black") .
COMPUTE IAT_AMP_race_filter$ = (combined_filter$=1 & orgn = "us" & race ne "black") .
EXECUTE .
 
VARIABLE LABELS iat_filter$ "1=clean IAT data" .
VARIABLE LABELS amp_filter$ "1=outliers removed AMP data " .
VARIABLE LABELS combined_filter$ "1=IAT & AMP data OK" .
FREQUENCIES amp_filter$ iat_filter$ combined_filter$ IAT_race_filter$ AMP_race_filter$
   IAT_AMP_race_filter$ .

DESCRIPTIVES race_IATall_d race_AMP_d .
COMPUTE amp_filter4$ = (race_amp_d >= -3.97 AND race_amp_d <= 4.07) .
COMPUTE amp_filter5$ = (race_amp_d >= -4.97 AND race_amp_d <= 5.07) .
COMPUTE filter$ = (amp_filter4$=0) .
FILTER BY filter$ .
LIST VARIABLES = subject D_biep_all amp .
CORRELATIONS race_IATall_d race_amp_d .
FILTER OFF .
COMPUTE filter$ = (amp_filter$=0) .
FILTER BY filter$ .
CORRELATIONS race_IATall_d race_amp_d .
FILTER OFF .

COMPUTE citizen = (orgn = "us") .
FREQUENCIES citizen black VoteMcCain forcechoice_McCain .
IF (MISSING(VoteMcCain) = 0) scaled_vote = VoteMcCain * 3 / 3.
IF (MISSING(forcechoice_McCain) = 0) scaled_vote = forcechoice_McCain / 3 .
IF (MISSING(VoteMcCain) = 0) forced_vote = VoteMcCain .
IF (MISSING(forcechoice_McCain) = 0) forced_vote = forcechoice_McCain - 1 .
FREQUENCIES scaled_vote forced_vote raceinfluence .

CROSSTABS black BY raceinfluence .

SAVE OUTFILE = "Mar_09_AMP_IAT_summary.sav" 
 / KEEP = 
    subject SESSION_ID session_date iatcond qtryhard qpushfast attrace qdeserve 
    Twhite qslavery Tblack forcechoice_McCain raceinfluence whovotechoose Tmccain Tobama
    attpol race_th_dif USER_ID sex age orgn race @_NAME amp amp1 amp2 namp mamp 
    voteObama cand_th_dif politicalID conservatism 
    VoteMcCain white mixed black citizen scaled_vote birthmonth birthyear citizenship class education engfluency 
    ethnicity income occupation religion religionid residence zipcode ethnicityomb genoccupation major raceomb 
    reldenom relfamily dayofbirth 
    symb_racism order position 
    D_biep_x D_biep_a D_biep_b Nx Na Nb D_biep D_biep_all 
    errorx errora errorb pct_300 pct_400 pct_2K pct_5K pct_10K
    aveltncy error_pct ntrials 
    race_IAT_d race_IATall_d race_IATx_d race_IATa_d race_IATb_d race_amp_d 
    race_th_df_d attrace_d cand_th_df_d attpol_d conservatism_d symb_racism_d 
    IAT_filter$ amp_filter$ amp_filter4$ amp_filter5$ combined_filter$ . 

*Use following to create SAS file for to anyone interested (probably a good idea to add some value labels first) .
*GET FILE =  "Mar_09_AMP_IAT_summary.sav" .
*SAVE TRANSLATE OUTFILE='Mar_09_AMP_IAT_summary.sas7bdat'
  /TYPE=SAS /VERSION=7 /PLATFORM=WINDOWS /MAP /REPLACE .

